package com.bye.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bye.dto.CustomerDto;
import com.bye.dto.ProductCategoryDto;
import com.bye.dto.ProductInfoDto;
import com.bye.mapper.ProductMapper;
import com.bye.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public String accountProduct() {
        Long l = productMapper.selectCount(null);
        String result = l.toString();
        return result;
    }

    @Override
    public List<ProductInfoDto> selectProductsOfConsume() {
        QueryWrapper qr = new QueryWrapper();
        qr.orderByDesc("sales_volume");
        qr.last("limit 10");
        List<ProductInfoDto> list = productMapper.selectList(qr);
        return list ;
    }

}
